package cn.iocoder.yudao.module.member.address.api;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.api.member.address.MemberAddressApi;
import cn.iocoder.yudao.module.api.member.address.dto.MemberAddressRespDTO;
import cn.iocoder.yudao.module.member.address.service.AddressService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * 用户地址 API 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
public class MemberAddressApiImpl implements MemberAddressApi {

    @Resource
    private AddressService addressService;

    @Override
    public MemberAddressRespDTO getAddress(Long id, Long userId) {
        return BeanUtils.toBean(addressService.getAddress(userId, id), MemberAddressRespDTO.class);
    }

    @Override
    public MemberAddressRespDTO getDefaultAddress(Long userId) {
        return BeanUtils.toBean(addressService.getDefaultAddress(userId), MemberAddressRespDTO.class);
    }

    @Override
    public MemberAddressRespDTO getDineAddress(Long userId) {
        return BeanUtils.toBean(addressService.getDineAddress(userId), MemberAddressRespDTO.class);
    }

}
